package com.dt76.smallloanbackendservice.controller.afterloan;



import com.dt76.smallloanbackendservice.pojo.afterloan.PrepaymentCommitInfo;
import com.dt76.smallloanbackendservice.service.afterloan.RepaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;


@Controller
public class PrepaymentController {

    private final RepaymentService repaymentService;

    public PrepaymentController(RepaymentService repaymentService) {
        this.repaymentService = repaymentService;
    }

    @GetMapping("/prepaymentManager")
    public String jumpToRepayment() {
        return "/pages/afterloan/prepaymentManager";
    }


    @ResponseBody
    @PostMapping("/prepayment/commitRepaymentConfirm")
    public Map<String, Object> commitRepaymentConfirm(@RequestBody PrepaymentCommitInfo q, @PathVariable Integer loanId) {
        Map<String,Object> map = new HashMap<>();
        map.put("res",repaymentService.modifyPrepaymentInfo(q, loanId));
        return map;
    }
}
